<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta name="renderer" content="webkit" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
  <title>千峰教育大前端Vue教学</title>
  <!-- 引入vue -->
  <script src="https://cdn.staticfile.org/vue/3.0.5/vue.global.js"></script>
</head>

<body style="margin:100px;font-size:22px;">
  <!-- 定义一个容器 -->
  <div id="app">
    <!-- 声明模板内容 -->
    <div>
      <div>我姓{{firstName}}，叫{{lastName}}，全名：{{fullName}}</div>
    </div>
  </div>
  <script>
    const {
       createApp,
       onBeforeMount,
       onMounted,
       onBeforeUpdate,
       onUpdated,
       onBeforeUnmount,
       onUnmounted,
    } = Vue;
    const app = createApp({
      setup() {
        onBeforeMount(() => { // 挂载前
          console.log('onBeforeMount')
        });
        onMounted(() => { // 已挂载
          // DOM操作、数据请求、实例化、计时器、延时器、订阅数据
          console.log('onMounted')
        });
        onBeforeUpdate(() => { // 更新前
          console.log('onBeforeUpdate')
        });
        onUpdated(() => { // 已更新
            // DOM操作、实例化
          console.log('onUpdated')
        });
        onBeforeUnmount(() => { // 卸载前
          // 取消订阅，清除计时器、延时器等
          console.log('onBeforeUnmount')
        });
        onUnmounted(() => { // 已卸载
          console.log('onUnmounted')
        });
        return () => 'hello world'
      },
    });
    // 挂载应用
    app.mount('#app');
  </script>
</body>

</html>